home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programmer Power Tools
/
Programmer Power Tools.iso
/
microcrn
/
issue_32.arc
/
PASCAL.FIG
< prev
next >
Wrap
Text File
|
1979-12-31
|
4KB
|
113 lines
((Pascal Fig. 1 - Search & Display Program for MS-DOS))
Program get_directory; { MS-DOS version 2 or above }
const
get_dta = $2f00; { get DTA address fxn }
srch_first = $4e00; { search first matching file }
srch_next = $4f00; { search next matching file }
srch_attr = $0000; { don't use file attributes in search }
type
regset = record { image of processor registers }
ax,bx,cx,dx,bp,si,di,ds,es,flags : integer;
end;
dtatype = record { image of Disk Transfer Area }
null : array [0..20] of byte; { used by DOS }
attr : byte; { file attribute spec }
time : integer; { coded time of day }
date : integer; { coded date }
fsiz : array [0..1] of integer; { file size in bytes }
fname : array[0..12] of char; { filename, punctuated }
end;
dtaptr = ^dtatype;
var
regs : regset;
curnt_dta : dtaptr;
searchname : string[64]; { room for a complete path }
i : integer;
begin
regs.ax := get_dta; { request code to proper place }
msdos(regs); { get and assign DTA address }
curnt_dta := ptr(regs.es,regs.bx);
searchname := 'DATA4*.JNK'+^@; { what files are we searching? }
regs.cx := srch_attr; { search attributes }
regs.ax := srch_first;{ request code }
regs.ds := seg(searchname[1]); { let DOS know where the string is }
regs.dx := ofs(searchname[1]);
msdos(regs); { find first occurence }
if regs.ax = 18 then { unsuccessful? }
writeln('No matching files') { what went wrong? }
else
while regs.ax <> 18 do { while we're successful }
begin
writeln; { for demo, just ship to screen }
i := 0; { character array pointer }
while (curnt_dta^.fname[i] <> ^@) and (i <= 12) do
begin
write(curnt_dta^.fname[i]);
i := succ(i);
end;
regs.ax := srch_next; { repeat the search }
msdos(regs);
end;
end.
=-=--=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
((Pascal Fig. 2 -- Search & Display Program for CP/M))
Program get_cpm_dir; ( CP/M version 2.2 }
const
set_dma = $1a; { won't use default DMA buffer for CP/M }
srch_first = $11; { request codes as above }
srch_next = $12;
type
fcb = record { image of what CP/M expects }
drive : byte; { drive spec }
fname : array[0..10] of char; { filename }
extent : byte; { extent (16K block) number }
s1,s2 : byte;
rc : byte; { record count for file }
map : array [0..15] of byte; { disk allocation blocks used }
curr_rec : byte; { current record for read/write }
rndm_rec : array[0..2] of byte; { random I/O record }
end;
var
result, i : integer;
dma : array[0..127] of byte;
our_fcb : fcb;
begin
bdos(set_dma,addr(dma)); { make CP/M put it where we want }
our_fcb.drive := 0; { default drive }
our_fcb.fname := 'DATA4???JNK'; { this is what we want }
our_fcb.s2 := 0;
our_fcb.extent := 0;
result := bdos(srch_first,addr(our_fcb)); { is anybody home? }
if result <> 255 then { gotcha? }
while result <> 255 do { yeah, loop til not gotcha }
begin
result := result shl 5; { result * 32 = filename address offset in DMA }
writeln;
for i := result + 1 to result + 11 do { 8 char name, 3 char extension }
begin
write(chr(dma[i]));
if i - result = 8 then write('.'); { proper punctuation }
end;
result := bdos(srch_next);
end
else writeln('No matching files found.'); { sorry about that }
end.